/**
 *
 *
 * API:
 * ----------------------
 * getBPMObjectType()
 * fromXML(xmlNode)
 * getFromId()
 * getToId()
 * getId()
 * getFromNode()
 * getToNode()
 * getConditionType();
 * getIsForce();
 * getConditionBase();
 * getConditionTitle();
 */
(function(global){

    'use strict';

    const logger = WorkflowUtil.newLogger("WorkflowApp/BPMTransition");

    let BPMTransition = function () {

        BPMTransition.__super__.constructor.apply(this, arguments);

        this.addAttr("id", "", "i");
        this.addAttr("name", "", "n");
        this.addAttr("type", "", "t");

        this.addAttr("desc", "", "d");
        this.addAttr("fromId", "", "k");
        this.addAttr("toId", "", "j");
        this.addAttr("sortIndex", "", "o");

        //1,2,3,4{1，4:没有区别，自动分支，2：手动分支，3：普通线，没有分支}
        this.addAttr("conditionType", "", "h");
        this.addAttr("formCondition", "", "m");//分支条件表达式
        this.addAttr("conditionId", "", "e");// 好像没有用到了
        this.addAttr("isForce", "", "b");
        this.addAttr("conditionBase", "", "a");
        this.addAttr("conditionTitle", "", "c");// 分支条件解释信息


        this.fromNode = null;
        this.toNode = null;
    };
    //继承
    WorkflowUtil.extend(BPMTransition, global.BPMObject);


    BPMTransition.prototype.getBPMObjectType = function(){
        return WorkflowConstant.bpmObjType.BPMTransition;
    };

    
    
    BPMTransition.prototype.getFromId = function(){
      return this.getAttr("fromId");
    };

    BPMTransition.prototype.getToId = function(){
      return this.getAttr("toId");
    };
    
    BPMTransition.prototype.getId = function(){
        return this.getAttr("id");
    };
    
    BPMTransition.prototype.getConditionType = function(){
        return this.getAttr("conditionType");
    };
    BPMTransition.prototype.getIsForce = function(){
        return this.getAttr("isForce");
    };
    BPMTransition.prototype.getConditionBase = function(){
        return this.getAttr("conditionBase");
    };
    BPMTransition.prototype.getConditionTitle = function(){
        return this.getAttr("conditionTitle");
    };
    
    
    BPMTransition.prototype.getFromNode = function(){
        return this.fromNode;
    };
    
    BPMTransition.prototype.getToNode = function(){
        return this.toNode;
    };
    
    BPMTransition.prototype.setPairNodes = function(fromNode, toNode){
        
        this.fromNode = fromNode;
        this.toNode = toNode;
    };


    /**
     * 从xml中解析连线
     * @param xmlNode
     */
    BPMTransition.prototype.fromXML = function(xmlNode){

        //读取属性
        this.transXMLNode2BPMObject(xmlNode);
        
       /*
        
        // flash的逻辑， 不知道还有没有用， 暂时不删除
         
        bendpoints.splice(0);
        var child:XMLNode = xml.firstChild;
        while (child != null)
        {
            var point = new Object();
            point.x = Number(child.attributes.x);
            //point.y = Number(child.attributes.y)+20;
            point.y = Number(child.attributes.y);
            bendpoints.push(point);
            child = child.nextSibling;
        }*/
    };

    BPMTransition.prototype.toXML = function(pNode, docRoot){

        const linkNode = docRoot.createElement("l");
        pNode.appendChild(linkNode);

        this.parseAttr2Node(linkNode);
    };

    global.BPMTransition = BPMTransition;
})(WorkflowApp);
